#!/usr/bin/perl
#
#

open(FILE1,$ARGV[0]);
open(FILE2,$ARGV[1]);

@linesFile1 = <FILE1>;
@linesFile2 = <FILE2>;

if(@linesFile1!=@linesFile2) {
	die "Number of lines not same\n";
}

for($i=0;$i<@linesFile1;$i++) {
	my(@wordsFile1) = split(/\s+/,$linesFile1[$i]);
	my(@wordsFile2) = split(/\s+/,$linesFile2[$i]);
	my(@commonWords);
	my(@onlyInFile1);
	my(@onlyInFile2);

	my(%wordsInFile1,%wordsInFile2,%allWords);
	foreach $word (@wordsFile1) {
		$wordsInFile1{$word} = 1;
		$allWords{$word} = 1;
	}
	foreach $word (@wordsFile2) {
		$wordsInFile2{$word} = 1;
		$allWords{$word} = 1;
	}

	foreach $word (keys %allWords) {
		if($wordsInFile1{$word} && $wordsInFile2{$word}) {
			push(@commonWords,$word);
		}	
		elsif($wordsInFile1{$word}) {
			push(@onlyInFile1,$word);
		}
		elsif($wordsInFile2{$word}) {
			push(@onlyInFile2,$word);
		}
	}

	print "COMMON: ".join(' ',sort @commonWords)."\n";
	print "GOLD:   ".join(' ',sort @onlyInFile1)."\n";
	print "PRED:   ".join(' ',sort @onlyInFile2)."\n\n";
}
